# 2008-03-20
# Makefile for the demos, modified by
# Manfred Brauchle <info@brauchle-consulting.de>
#
# don't forget to create your octopus.o
# by calling 'make win' in ../../octobus/libs/c
#
#

# hopefully the check for WINDIR works for everybody ...

ifndef WINDIR
##############################################################################
# linux version ...

all:
	gcc -g -o demo demo.c -loctopus
	gcc -g -o adc adc.c -loctopus
	#gcc -g -o i2c i2c.c -loctopus
	gcc -g -o togl togl.c -loctopus
	gcc -g -o spi spi.c -loctopus
	gcc -g -o io_input io_input.c -loctopus
	gcc -g -o threaddemo threaddemo.c -loctopus -lpthread

clean:
	rm demo

else
##############################################################################
# windows / msys version ...

WIN_LIBUSB_DIR         = ../../drivers/windows/libusb-win32-device-bin-0.1.12.1
WIN_LIBUSB_INCLUDE_DIR = $(WIN_LIBUSB_DIR)/include
WIN_LIBUSB_LIB_DIR_GCC = $(WIN_LIBUSB_DIR)/lib/gcc/libusb.a

CC_PARAM = -D 'sleep(s)=Sleep(s*1000)' \
		-I../../liboctopus/src \
		-I$(WIN_LIBUSB_INCLUDE_DIR) \
		../../libs/c/octopus.o \
		$(WIN_LIBUSB_LIB_DIR_GCC)

winall: demo.exe adc.exe spi.exe togl.exe io_input.exe i2c.exe threaddemo.exe

%.exe: %.c
	gcc $< -o $@ $(CC_PARAM)

threaddemo.exe: threaddemo.c
	gcc $< -o $@ $(CC_PARAM) -lpthread

endif
